class Solution {
public:
    vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
        vector<int> res;
        if(k == 0 || k > input.size()) return res;
        priority_queue<int> pq;
        for(int i : input){
            if(pq.size() < k) pq.push(i);
            else{
                if(i < pq.top()){
                    pq.pop();
                    pq.push(i);
                }
            }
        }
        
        while(!pq.empty()){
            res.push_back(pq.top());
            pq.pop();
        }
        return res;
    }
};